package utn.bi.DAO.conn;

public class SQLServerConnection extends AbstractConnection {

	private final String DEFAULT_PORT = "1434";
	
	private final String JDBC_DRIVER = "jdbc:sqlserver://";
	
	// TODO [Hugo] Constructores !!!!
	public SQLServerConnection(String userDB, String passDB, String hostDB, String portDB){
		this.userDB = userDB;
		this.passDB = passDB;
		this.hostDB = hostDB;
		this.portDB = portDB;
	}
	
	public SQLServerConnection(){
	}
	
	/**
	 * The general form of the connection URL is <br/>
     * jdbc:sqlserver://[serverName[\instanceName][:portNumber]]
     *
	 */
	protected String getUrl() {
		StringBuilder urlConn = new StringBuilder(JDBC_DRIVER);
		urlConn.append(getHostDB());
		// FIXME Considerar la instancia !!! (se pone la instancia x defecto "sin nombre")
		urlConn.append(":");
		urlConn.append(getPortDB());
		return urlConn.toString();
	}

	
	
	public String getPortDB() {
		if(portDB == null || portDB.length() == 0)
			return DEFAULT_PORT;
		else 
			return portDB;
	}
	
	
}
